package com.leetao.ifkiller.domain;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 菅江晖
 * @date 2021/6/11 - 0:40
 */
public class Command<T> {
    private final List<PredicatePro<T>> conditions = new LinkedList<>();
    private final ConsumerPro<T> consumerPro;


    public Command(List<PredicatePro<T>> conditions, ConsumerPro<T> consumer) {
        this.conditions.addAll(conditions);
        this.consumerPro = consumer;
    }

    public List<PredicatePro<T>> getConditions() {
        return conditions;
    }

    public ConsumerPro<T> getConsumerPro() {
        return consumerPro;
    }

    public String showCommand() {
        String condition = conditions.stream().map(PredicatePro::getDescription).collect(Collectors.joining(" && "));
        String operation = consumerPro.getDescription();
        return "condition: " + condition + " -> operation: " + operation;
    }


}
